// by mornstar
// Jun/07/2023 00:27
#include <bits/stdc++.h>
using namespace std;
int n, a[200005], ans;
int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        ans = INT_MAX;
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        if (n <= 3)
        {
            cout << 0 << "\n";
            continue;
        }
        sort(a + 1, a + n + 1);
        for (int i = 1; i <= n - 2; i++)
        {
            if ((a[i] - a[1] + 1) / 2 >= ans)
                break;
            // 同上
            int l = i + 1, r = n;
            while (l < r)
            {
                int mid = (l + r) >> 1;
                ans = min(ans, (max(max(a[i] - a[1], a[mid] - a[i + 1]), a[n] - a[mid + 1]) + 1) / 2);
                if ((a[mid] - a[i + 1] + 1) / 2 <= (a[n] - a[mid + 1] + 1) / 2)
                    l = mid + 1;
                else
                    r = mid;
            }
            // 二分
        }
        cout << ans << "\n";
    }
}
